package com.xjgc.eip.db;

import com.xjgc.eip.service.ZxjEip2CPutService;


public class DbTest {
	public static void main(String[] args) {
//		String flag = "\"346696126689366016\"";
//		System.out.println(flag.substring(1, flag.length()-1));

		//post();
		new ZxjEip2CPutService().putData();
		
		/*try {
			DbConn db = new DbConn();
			Connection con = db.getConnetion();
			//con = dbConn("q1w2e3r4","q1w2e3r4");
			if (con == null) {
				System.out.print("连接失败");
				System.exit(0);
			}
			
			
			//String url = "select * from zxj_eip_2chjwsd";			
			
			//////////////
			Date date = new Date();
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
			SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
			
			String startDate1 = "2018-08-03T10:00:00.000Z";
			String startDate2 = "2019-08-03T10:00:00.000Z";
			String str1 = sdf2.format(sdf1.parse(startDate1));
			String str2 = sdf2.format(sdf1.parse(startDate2));
			System.out.println(str1);
			System.out.println(str2);
			
			//String url = "select * from zxj_eip_2chjwsd where collecttimw Between to_date("+startDate1+",'yyyy-mm-dd hh24:mi:ss') And to_date("+startDate2+",'yyyy-mm-dd hh24:mi:ss')";
			String url = "select * from zxj_eip_2chjwsd where collecttimw Between to_date('"+startDate1+"','yyyy-mm-dd hh24:mi:ss') And to_date('"+startDate2+"','yyyy-mm-dd hh24:mi:ss')";
			//
			PreparedStatement pres =  con.prepareStatement(url);
			System.out.println(pres.execute(url));
			ResultSet rs = null;
			rs = pres.executeQuery();

			while (rs.next()) {
				
//				ZxjEip2CVbeln zxjEipVbeln = new ZxjEip2CVbeln(rs.getString("no"), rs.getString("id"), rs.getString("suppliername"), rs.getString("customerorderno"), 
//						rs.getString("customername"), rs.getString("projectname"), rs.getString("tendersbatchno"), rs.getString("orderdate"), rs.getString("demanddate"), 
//						rs.getString("determinedate"), rs.getString("shipmentdate"), rs.getString("status"),rs.getString("shipmentstatus"), rs.getString("deliverystatus"), 
//						rs.getString("tags"), rs.getString("labels"));
//				
//				System.out.println(rs.getString("no")+ ","+ rs.getString("id")+ ","+  rs.getString("suppliername")+ ","+  rs.getString("customerorderno")+ ","+  
//						rs.getString("customername")+ ","+  rs.getString("projectname")+ ","+  rs.getString("tendersbatchno")+ ","+  rs.getString("orderdate")+ ","+  rs.getString("demanddate")+ ","+  
//						rs.getString("determinedate")+ ","+  rs.getString("shipmentdate")+ ","+  rs.getString("status")+ ","+ rs.getString("shipmentstatus")+ ","+ rs.getString("deliverystatus")+ ","+  
//						rs.getString("tags")+ ","+  rs.getString("labels"));
				System.out.println(sdf1.format(rs.getDate("supplier")) );
			}

//			rs.close();
//			pres.close();
//			
//			String url2 = "select * from zxj_eip_2cgxbg";
//			pres =  con.prepareStatement(url2);
//			rs = pres.executeQuery();
//
//			while (rs.next()) {
//				System.out.println("=="+rs.getString("salesorderno"));
//			}
			
			rs.close();
			pres.close();
			con.close();
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}*/
	}
	
	/*
	// 调用汇集服务接口,推送生产工序报工表数据
	public static String post() {
		
		Form form = new Form();
		//form.param("grant_type", "client_credentials").param("scope", "oms.ord").param("client_id", "oms@XuJiJiTuan2").param("client_secret", "a56597a7-a924-4f94-a225-b44546fa73dc");
		form.param("grant_type", "client_credentials").param("scope", "oms.ord").param("client_id", "oms@XuJiJiTuan2").param("client_secret", "e69e16dd-47cc-4c07-a966-ea14acc426b8");
		
		//String serverUri = "https://service.oms.cxist.com:8443";
		String serverUri = "http://service.oms.xuji.iubang.com";
		Client client = ClientBuilder.newClient();
		WebTarget target = client.target(serverUri + "/ids/connect/token");
        
        Response response=null;
		try {
			response = target.request(MediaType.APPLICATION_FORM_URLENCODED).buildPost(Entity.form(form)).submit(Response.class).get();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

        String result = response.readEntity(String.class);
        JSONObject obj = JSONObject.parseObject(result);
        System.out.println(response.getStatus()+"*********************************"+obj.getString("access_token"));
        
//        test zxjEip2CVbeln = new test("201908071015", "201908071015", "201908071015", "201908071015", 
//        		"201908071015", "201908071015", "201908071015", "2019-08-07T02:17:01.005Z", "2019-08-07T02:17:01.005Z", 
//        		"2019-08-07T02:17:01.005Z", "1","1",new String[]{"jinagsu"},"remark","thirdPartyId","thirdPartyExtensions",new testRemark(""),
//        		"2019-08-07T02:17:01.005Z", "1","10","1001","987665313451234323","987665313451234323","987665313451234323");
        
        ZxjEip2CVbeln zxjEip2CVbeln = new ZxjEip2CVbeln("201908071016", "201908071016", "201908071015", "201908071015", 
        		"201908071015", "201908071015", "201908071015", "2019-08-07T02:17:01.005Z", "2019-08-07T02:17:01.005Z", 
        		"2019-08-07T02:17:01.005Z", "2019-08-07T02:17:01.005Z", "1","1", "1", 
        		new String[]{"jinagsu"}, new Remark(""), "10","1001");
        
        Form form1 = new Form();
        form1.param("no", "201908071015").param("supplierName", "string").param("customerOrderNo", "string").
        	param("customerName", "string").param("projectNo", "string").param("projectName", "201908071015").param("tendersBatchNo", "201908071015").
        	param("orderDate", "2019-08-07T02:17:01.005Z").param("demandDate", "2019-08-07T02:17:01.005Z").param("shipmentDate", "2019-08-07T02:17:01.005Z").
        	param("status", "1").param("shipmentStatus", "1").param("tags", "jiangsu").param("remark", "string").param("thirdPartyId", "string").param("thirdPartyExtensions", "string").
        	param("labels", "123").param("determineDate", "2019-08-07T02:17:01.005Z").param("deliveryStatus", "1").param("categoryCode", "10").param("materialClassCode", "1001").
        	param("openTenantId", "987665313451234323").param("id", "987665313451234323").param("tenantId", "987665313451234323");
        
				
        WebTarget target1 = client.target(serverUri + "/Oms/Ord/SalesOrder");
        Response response1=null;
//		try {
//			response1 = target1.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer "+obj.getString("access_token")).header(HttpHeaders.CONTENT_TYPE, "application/json")
//			.buildPost(Entity.form(form)).submit(Response.class).get();
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (ExecutionException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
        System.out.println(JSON.toJSONString(zxjEip2CVbeln));
        System.out.println(target1.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer "+obj.getString("access_token")));
		response1 = target1.request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, "Bearer "+obj.getString("access_token")).//header(HttpHeaders.CONTENT_TYPE, "application/json").
				//post(Entity.entity(JSON.toJSONString(form1),MediaType.APPLICATION_JSON));
		
				buildPost(Entity.entity(JSON.toJSONString(zxjEip2CVbeln), MediaType.APPLICATION_JSON)).invoke();  
        String result1 = response1.readEntity(String.class);
        System.out.println(result1+"*********************************"+response1.getStatusInfo().toString());
		//System.out.println(response2);
        response1.close();
        return result1;
	}*/

}
